package com.qqletter.utils;

import org.codehaus.jackson.map.ObjectMapper;

import com.qqletter.response.BaseResponse;


/**
 * @author Devin.Hu
 * @date 2011-8-14
 * @version V1.0
 * @description json数据解析类
 */
public class ObjectJsonParser <T extends BaseResponse>{
	
	private Class<T> clazz;
	private ObjectMapper objectMapper;
	
	public ObjectJsonParser(Class<T> clazz) {
		this.clazz = clazz;
	}

	public T parse(String rsp) throws Exception {
		objectMapper = new ObjectMapper();  
		return objectMapper.readValue(rsp, clazz);
	}

	public Class<T> getResponseClass() {
		return clazz;
	}
}
